from quart import ResponseReturnValue

from util import route, render_template
from quart_auth import login_required, login_user, AuthUser, logout_user
from util.db import db

bp = route(__name__)

@bp.get("/")
async def home():
    res = db('user').limit(10).as_dict()
    return await render_template('/index/test.html', res=res)
    # return await render_template('/index/index.html', res=res)


@bp.get("/test")
@login_required
async def test():
    res = db('user').limit(10).as_dict()
    return await render_template('/index/index.html', res=res)


@bp.route("/login")
async def login() -> ResponseReturnValue:
    logout_user()
    # login_user(AuthUser("2"))
    return "login"